////////////////////////////////////////////////////////////////////////////////
// File:        DownloadLicensesFrm.h
// Purpose:     Form to download licenses in an easy mode
// Author:      Tukero
// Copyright:   (c) Tukero <tukero@gmail.com>
// Licence:     GNU/LGPL v3
////////////////////////////////////////////////////////////////////////////////

#ifndef __DOWNLOADLICENSESFRM_H__
#define __DOWNLOADLICENSESFRM_H__

#ifdef __BORLANDC__
	#pragma hdrstop
#endif

#ifndef WX_PRECOMP
	#include <wx/wx.h>
	#include <wx/frame.h>
#else
	#include <wx/wxprec.h>
#endif

#include "Multilanguage.h"
#include "License.h"

//Do not add custom headers between 
//Header Include Start and Header Include End.
//wxDev-C++ designer will remove them. Add custom headers after the block.
////Header Include Start
#include <wx/checkbox.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/spinctrl.h>
#include <wx/stattext.h>
#include <wx/listctrl.h>
#include <wx/panel.h>
#include <wx/sizer.h>
////Header Include End

////Dialog Style Start
#undef DownloadLicensesFrm_STYLE
#define DownloadLicensesFrm_STYLE wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxCLOSE_BOX
////Dialog Style End

class DownloadLicensesFrm : public wxFrame
{
	private:
		DECLARE_EVENT_TABLE();
		
	public:
		DownloadLicensesFrm(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("DownloadLicenses"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = DownloadLicensesFrm_STYLE);
		virtual ~DownloadLicensesFrm();
		
	private:
        //Multilanguage Lang;
		//Do not add custom control declarations between
		//GUI Control Declaration Start and GUI Control Declaration End.
		//wxDev-C++ will remove them. Add custom code after the block.
		////GUI Control Declaration Start
		wxButton *m_btnClose;
		wxCheckBox *m_chkCheckExpirationDates;
		wxButton *m_btnDownload;
		wxStaticLine *m_linSeparator;
		wxButton *m_btnSave2File;
		wxSpinCtrl *m_spinLicenses2Check;
		wxStaticText *m_lblLicenses2Check;
		wxSpinCtrl *m_spinLicenses2Download;
		wxStaticText *m_lblLicenses2Download;
		wxFlexGridSizer *m_flxDownloadOptions;
		wxListCtrl *m_lvwLicenses;
		wxStaticBoxSizer *m_bxsOptions;
		wxBoxSizer *m_sizerDrawing;
		wxPanel *m_panMain;
		wxBoxSizer *m_boxMain;
        wxStaticText *m_lblLicesesValidFor;
        wxComboBox *m_cboProductType;
		////GUI Control Declaration End

        wxCommandEvent  *m_DownloadEvent;
        long             m_indexOfSelection;
        wxThread*        m_runningThread;
        wxThread*        m_insertionThread;

        wxCriticalSection   m_MutexListView;
        
        int              m_RunsWithoutUpdate;
        bool             m_checkExpirationDates;
        int              m_oldProductSelection;
	private:
		//Note: if you receive any error with these enum IDs, then you need to
		//change your old form code that are based on the #define control IDs.
		//#defines may replace a numeric value for the enum names.
		//Try copy and pasting the below block in your old form header files.
		enum
		{
			////GUI Enum Control ID Start
			ID_M_BTNCLOSE = 1038,
			ID_M_CHKCHECKEXPIRATIONDATES = 1037,
			ID_M_BTNDOWNLOAD = 1036,
			ID_M_LINSEPARATOR = 1033,
			ID_M_BTNSAVE2FILE = 1029,
			ID_M_SPINLICENSES2CHECK = 1028,
			ID_M_LBLLICENSES2CHECK = 1027,
			ID_M_SPINLICENSES2DOWNLOAD = 1026,
			ID_M_LBLLICENSES2DOWNLOAD = 1019,
			ID_M_CBOPRODUCTTYPE = 1041,
			ID_M_LBLLICESESVALIDFOR = 1039,
			ID_M_LVWLICENSES = 1009,
			ID_M_PANMAIN = 1002,
			////GUI Enum Control ID End
            ID_RECEIVEEVENTS,
            ID_ITEM_INSERTLICENSE,
            ID_ITEM_COPYUSERNAME,
            ID_ITEM_COPYPASSWORD,
            ID_ITEM_COPY2CLIPBOARD,
			ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
		};
		
	private:
		void OnClose(wxCloseEvent& event);
        void OnBtnDownload(wxCommandEvent& event);
        void OnBtnClose(wxCommandEvent& event);
        void OnBtnSave2File(wxCommandEvent& event);
        void OnExternalEvent(wxCommandEvent& event);
        void OnInsertLicense(wxCommandEvent& event);
        void OnCopyUsername(wxCommandEvent& event);
        void OnCopyPassword(wxCommandEvent& event);
        void OnCopy2Clipboard(wxCommandEvent& event);
        void OnLvwRightClick(wxListEvent& event);
        void InsertLic2ListView(License *license);
		void CreateGUIControls();
        void GetItemData(int index, wxString& username, wxString& password, wxString& expiration);
        void UpdateFirstColText();
};

#endif
